/*
 * Copyright (C) 2012  Romain DUBOIS
 * 
 * This file is part of NeMoS - Network and Modular Software
 * 
 * NeMoS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * NeMoS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with NeMoS.  If not, see <http://www.gnu.org/licenses/>.
 */
package nemos.remote;

import org.osgi.framework.ServiceReference;

/**
 * IInterceptor : The interceptor interface.
 * 
 * <p>
 * Services registered under this interface are called during the invocation of
 * a local service required by a remote framework.
 * </p>
 * 
 * <p>
 * The order of the interceptors call is the natural {@link ServiceReference}
 * ordering. Services with a ranking positive or 0 are called before the service
 * call while services whith negative ranking are called after the service
 * invocation. This means that later ones can modify the returned result while
 * first ones can modify invocation elements (method, arguments, service and
 * service reference).
 * </p>
 * 
 * <p>
 * Any exception thrown during an interceptor call stop the process. Next
 * interceptors are not called.
 * </p>
 * 
 * <p>
 * An interceptor can specify the services it is interested in intercepting the
 * calls. It has to fill the {@link #INTERCEPTOR_SCOPE} property with a filter
 * with a valid LDAP syntax. No value will mean all remote calls.
 * </p>
 * 
 * @author Romain DUBOIS
 */
public interface IInterceptor {

    /**
     * Only services matching the filter contained in this property are
     * intercepted
     */
    String INTERCEPTOR_SCOPE = "nemos.remote.interceptor.scope"; //$NON-NLS-1$

    /**
     * Intercept a remote call.
     * 
     * @param pCall
     *            The remote call
     * @throws Exception
     *             If the process must stop
     */
    void interceptInvocation(RemoteCall pCall) throws Exception;
}
